//
//  AnchorCollectionViewCellFirst.m
//  XYFMApp
//
//  Created by 岁变 on 16/9/3.
//  Copyright © 2016年 岁变. All rights reserved.
//

#import "AnchorCollectionViewCellFirst.h"
#import "XYMacro.h"

@implementation AnchorCollectionViewCellFirst

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        
        self.contentView.backgroundColor = [UIColor whiteColor];
        _backImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_backImageView];
        
        _frontImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"friend_item_head"]];
        [self.contentView addSubview:_frontImageView];
        
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = [UIFont systemFontOfSize:15];
        _titleLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:_titleLabel];
    }
    return self;
}

- (void)setModel:(AnchorModelSecondData *)model {
    _titleLabel.text = model.item_lastmusic;
    [_backImageView sd_setImageWithURL:[NSURL URLWithString:model.item_img] placeholderImage:PLACEHOLDERIMAGE];
}



- (void)layoutSubviews {
    
    [super layoutSubviews];
    [_backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).with.offset(0);
        make.left.equalTo(self.contentView.mas_left).with.offset(0);
        make.right.equalTo(self.contentView.mas_right).with.offset(-20);
        make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-30);
    }];
    
    [_frontImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).with.offset(0);
        make.left.equalTo(self.contentView.mas_left).with.offset(0);
        make.right.equalTo(self.contentView.mas_right).with.offset(0);
        make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-30);
    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_frontImageView.mas_bottom).with.offset(0);
        make.left.equalTo(self.contentView.mas_left).with.offset(0);
        make.right.equalTo(self.contentView.mas_right).with.offset(0);
        make.bottom.equalTo(self.contentView.mas_bottom).with.offset(0);
    }];
}


@end
